package org.vectrics.recruiter.struts.admin;

import javax.servlet.jsp.JspException;

import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.job.Job;
import org.vectrics.recruiter.user.ResumeScanBatch;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.struts.VectricsStrutsAction;

public class ResumeScanAttachJobAction extends VectricsStrutsAction {

	protected String doExecute(VectricsActionData actionData)
			throws JspException {
		String jobId = actionData.getRequest().getParameter("jobId");
		String scanId = actionData.getRequest().getParameter("scanId");
		Job job = RecruitServiceLocator.getJobProvider().findJob(new Long(jobId));
		ResumeScanBatch resumeScanBatch = RecruitServiceLocator.getRecruitUserService().findResumeScanBatch(new Long(scanId));
		
		RecruitServiceLocator.getRecruitUserService().createResumeScanBatchJob(job, resumeScanBatch);
		PrepareResumeScanFormAction.doWork(scanId, jobId, actionData.getRequest(), actionData.getMapping());
		actionData.getRequest().setAttribute("batchId", resumeScanBatch.getId().toString());
		return "success";
	}

}
